home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_emacs.idb / usr / freeware / src / emacs / patches.z / patches
Encoding:
Text File  |  1998-10-28  |  63.5 KB  |  2,093 lines

  1. *** ./etc/ctags.1    Fri Jul 17 12:58:29 1992
  2. --- ../emacs-19.34/./etc/ctags.1    Fri May 15 12:03:09 1998
  3. ***************
  4. *** 1 ****
  5. ! .so man1/etags.1
  6. --- 1 ----
  7. ! .so etags.1
  8. *** ./etc/gnuserv.1    Thu May 21 11:32:03 1998
  9. --- ../emacs-19.34/./etc/gnuserv.1    Fri May 15 14:18:35 1998
  10. ***************
  11. *** 0 ****
  12. --- 1,132 ----
  13. + .TH GNUSERV 1 "" "GNU Emacs Server"
  14. + .UC 4
  15. + .SH NAME
  16. + gnuserv, gnuclient, gnudoit \- Server and Clients for GNU Emacs
  17. + .SH SYNOPSIS
  18. + .B gnuclient
  19. + [-q] [[-h hostname] [-p port] [-r pathname]] [[+line] path] ...
  20. + .br
  21. + .B gnudoit 
  22. + [-q] [[-h hostname] [-p port]] [sexpr] ...
  23. + .br
  24. + .B gnuserv
  25. + .SH DESCRIPTION
  26. + \fIgnuclient\fP allows the user to request a running GNU Emacs process to edit
  27. + the named files or directories.
  28. + .PP
  29. + \fIgnudoit\fP allows the user to request a running GNU Emacs process to
  30. + evaluate the given arguments inside a progn LISP form.
  31. + .PP
  32. + \fIgnuserv\fP is the server program that is set running by GNU Emacs to handle
  33. + all incoming and outgoing requests. It is not usually invoked directly, but is
  34. + started from GNU Emacs by the LISP form (server-start).
  35. + .SH OPTIONS
  36. + .TP 8
  37. + .BI \-q
  38. + This option informs both \fIgnuclient\fP and \fIgnudoit\fP to exit once
  39. + connection has been made with the GNU Emacs process. Normally \fIgnuclient\fP
  40. + waits until all of the files on the command line have been finished with
  41. + (their buffers killed) by the GNU Emacs process, and \fIgnudoit\fP normally
  42. + waits around for evaluation of its arguments by the GNU Emacs process, and
  43. + prints the results or error conditions.
  44. + .TP 8
  45. + .BI \-h " hostname"
  46. + Used only with Internet-domain sockets, this option specifies the host machine
  47. + which should be running \fIgnuserv\fP.  If this option is not specified then
  48. + the value of the environment variable GNU_HOST is used if set, otherwise the
  49. + hostname of the machine running the program is used.
  50. + .br
  51. + Note that an internet address may be specified instead of a hostname which can
  52. + speed up connections to the server by quite a bit, especially if the client
  53. + machine is running YP.
  54. + .br
  55. + Note also that a hostname of \fBunix\fP can be used to specify that the connection
  56. + to the server should use a Unix-domain socket (if supported) rather than an
  57. + Internet-domain socket.
  58. + .TP 8
  59. + .BI \-p " port"
  60. + Used only with Internet-domain sockets, this option specifies the service port
  61. + used to communicate between server and clients. If this option is not
  62. + specified, then the value of the environment variable GNU_PORT is used, if
  63. + set, otherwise a service called ``gnuserv'' is looked up
  64. + in the services database. Finally, if no other value can be found for the
  65. + port, then a default port is used which is usually 21490 + uid.
  66. + .br
  67. + Note that since \fIgnuserv\fP doesn't allow command-line options, the port for
  68. + it will have to be specified via one of the alternative methods.
  69. + .TP 8
  70. + .BI \-r " pathname"
  71. + Used only with Internet-domain sockets, the pathname argument may be needed to
  72. + inform GNU Emacs how to reach the root directory of a remote machine.
  73. + \fIgnuclient\fP prepends this string to each path argument given. For example,
  74. + if you were trying to edit a file on a client machine called otter, whose root
  75. + directory was accessible from the server machine via the path /net/otter, then
  76. + this argument should be set to '/net/otter'. If this option is omitted, then
  77. + the value is taken from the environment variable GNU_NODE, if set, or the
  78. + empty string otherwise.
  79. + .br
  80. + Note that on hp9000/s300 and hp9000/s800, the pathname, if not specified by
  81. + the user, is guessed.
  82. + .TP 8
  83. + .BI "path"
  84. + This is the path of the file to be edited. If the file is a directory, then
  85. + the directory browsers dired or monkey are usually invoked instead.
  86. + .TP 8
  87. + .BI "sexpr"
  88. + This is part of a GNU Emacs LISP expression to evaluate. All the sexprs are
  89. + concatenated together and wrapped in a progn form before sending to GNU Emacs.
  90. + .PP
  91. + .SH SETUP
  92. + In order to use the programs, the file gnuserv.el can be copied into a
  93. + directory on your GNU Emacs load-path, and loaded into GNU Emacs by the GNU
  94. + Emacs LISP form (load "gnuserv"). The server can then be started by the GNU
  95. + Emacs LISP form (server-start).
  96. + .SH EXAMPLE
  97. + .TP 8
  98. + gnudoit -q '(mh-smail)'
  99. + .TP 8
  100. + gnuclient -h otter -r /net/otter /tmp/*
  101. + .SH SYSV IPC
  102. + SysV IPC is used to communicate between \fIgnuclient\fP, \fIgnudoit\fP and
  103. + \fIgnuserv\fP if the symbol SYSV_IPC is defined at the top of gnuserv.h. This
  104. + is incompatible with both Unix-domain and Internet-domain socket communication
  105. + as described below. A file called /tmp/gsrv??? is created as a key for the
  106. + message queue, and if removed will cause the communication between server and
  107. + client to fail until the server is restarted.
  108. + .SH UNIX-DOMAIN SOCKETS
  109. + A Unix-domain socket is used to communicate between \fIgnuclient\fP,
  110. + \fIgnudoit\fP and \fIgnuserv\fP if the symbol UNIX_DOMAIN_SOCKETS is defined
  111. + at the top of gnuserv.h.  A file called /tmp/gsrv??? is created for
  112. + communication and if deleted will cause communication between server and
  113. + client to fail.
  114. + .SH INTERNET-DOMAIN SOCKETS
  115. + Internet-domain sockets are used to communicate between \fIgnuclient\fP,
  116. + \fIgnudoit\fP and \fIgnuserv\fP if the symbol INTERNET_DOMAIN_SOCKETS is
  117. + defined at the top of gnuserv.h. Both Internet-domain and Unix-domain sockets
  118. + can be used at the same time.
  119. + .SH SECURITY
  120. + Using Internet-domain sockets, a more robust form of security is needed that
  121. + wasn't necessary with either Unix-domain sockets or SysV IPC.
  122. + .br
  123. + \fIgnuserv\fP performs a limited form of security at the machine level. By
  124. + default only connections from the host where the server is running will be
  125. + allowed. All other server connections will be rejected with a cryptic message
  126. + (which is displayed only by \fIgnudoit\fP). Alternatively, if the variable
  127. + GNU_SECURE can be found in \fIgnuserv\fP's environment, and it names a
  128. + readable filename, then this file is opened and assumed to be a list of hosts,
  129. + one per line, from which the server will allow requests. Note that a host may
  130. + be either a internet address, or a hostname. If this file contains a lot of
  131. + hostnames then the server may take quite a time to start up.
  132. + .SH KNOWN BUGS
  133. + If GNU Emacs attempts to send a string containing a newline character to
  134. + \fIgnuserv\fP, then \fIgnuserv\fP will die.
  135. + .SH FILES
  136. + .PP
  137. + .TP 8
  138. + .B /tmp/gsrv???
  139. + .TP 8
  140. + .B ~/.emacs
  141. + GNU Emacs customization file, see emacs(1).
  142. + .SH AUTHOR.
  143. + Andy Norman (ange@hplb.hpl.hp.com), based heavily upon etc/emacsclient.c,
  144. + etc/server.c and lisp/server.el from the GNU Emacs 18.52 distribution.
  145. *** ./src/m/iris4d.h    Tue Jul 23 14:28:12 1996
  146. --- ../emacs-19.34/./src/m/iris4d.h    Thu May 21 11:41:07 1998
  147. ***************
  148. *** 131,137 ****
  149.   
  150.   #undef LIBS_MACHINE
  151.   /* -lsun in case using Yellow Pages for passwords.  */
  152. ! #if defined(__GNUC__) && defined(_ABIN32)
  153.   #define LIBS_MACHINE
  154.   #else
  155.   #define LIBS_MACHINE -lmld
  156. --- 131,137 ----
  157.   
  158.   #undef LIBS_MACHINE
  159.   /* -lsun in case using Yellow Pages for passwords.  */
  160. ! #if defined(_ABIN32)
  161.   #define LIBS_MACHINE
  162.   #else
  163.   #define LIBS_MACHINE -lmld
  164. ***************
  165. *** 187,193 ****
  166. --- 187,197 ----
  167.      that we can't fix without breaking other machines.  */
  168.   #ifdef IRIX_FORCE_32_BITS
  169.   #ifdef THIS_IS_MAKEFILE
  170. + #ifdef _ABIN32
  171. + #define C_SWITCH_MACHINE -n32
  172. + #else
  173.   #define C_SWITCH_MACHINE -32
  174. + #endif
  175.   #endif
  176.   #endif
  177.   
  178. *** ./src/s/irix6-x.h    Thu May 21 11:32:03 1998
  179. --- ../emacs-19.34/./src/s/irix6-x.h    Thu May 21 11:42:19 1998
  180. ***************
  181. *** 0 ****
  182. --- 1,39 ----
  183. + #include "irix5-0.h"
  184. + /* Irix 6 prior to 6.2 tries to do 64 bits, but doesn't do it fully,
  185. +    so inhibit that.  */
  186. + /* #define IRIX_FORCE_32_BITS */
  187. + /* Define this for -n32, undef it for -o32 builds */
  188. + #define _ABIN32
  189. + #ifdef _ABIN32
  190. + # ifndef __GNUC__
  191. + #  define LD_SWITCH_SYSTEM -G0
  192. + #  undef  C_SWITCH_SYSTEM
  193. + #  define C_SWITCH_SYSTEM -xansi -G0
  194. + #  undef  C_DEBUG_SWITCH
  195. + # endif
  196. + # undef LOADLIBES
  197. + #else
  198. + # undef  C_SWITCH_SYSTEM
  199. + # define C_SWITCH_SYSTEM -mips2
  200. + # undef  C_DEBUG_SWITCH
  201. + # define C_DEBUG_SWITCH  -O2 -Olimit 3000
  202. + #endif
  203. + /* This macro definition, which we inherited from irix5-0.h,
  204. +    is needed in configure on Irix 5, but gets in the way there
  205. +    on Irix 6.  So get rid of it except in Makefile.in where we need it.  */
  206. + #ifndef THIS_IS_MAKEFILE
  207. + # undef C_SWITCH_SYSTEM
  208. + #endif
  209. + /* The only supported configuration of GCC under IRIX6.x produces
  210. +    n32 MIPS ABI binaries and also supports -g. */
  211. + #ifdef __GNUC__
  212. + # undef  C_DEBUG_SWITCH
  213. + # define C_DEBUG_SWITCH -g
  214. + #endif
  215. + #undef SA_RESTART
  216. *** ./src/s/irix5-0.h    Fri Jul 19 15:40:59 1996
  217. --- ../emacs-19.34/./src/s/irix5-0.h    Fri May 15 11:53:42 1998
  218. ***************
  219. *** 3,8 ****
  220. --- 3,11 ----
  221.   #define IRIX5
  222.   
  223.   /* We want BSD style signals. */
  224. + #ifdef _BSD_SIGNALS
  225. + #undef _BSD_SIGNALS
  226. + #endif
  227.   #define _BSD_SIGNALS
  228.   
  229.   #define SETPGRP_RELEASES_CTTY
  230. *** ./src/Makefile.in    Sat May 18 16:12:39 1996
  231. --- ../emacs-19.34/./src/Makefile.in    Fri May 15 10:42:41 1998
  232. ***************
  233. *** 734,740 ****
  234.   #ifdef HAVE_SHM
  235.       ./temacs -nl -batch -l loadup dump
  236.   #else /* ! defined (HAVE_SHM) */
  237. !     ./temacs -batch -l loadup dump
  238.   #endif /* ! defined (HAVE_SHM) */
  239.   #endif /* ! defined (CANNOT_DUMP) */
  240.   
  241. --- 734,740 ----
  242.   #ifdef HAVE_SHM
  243.       ./temacs -nl -batch -l loadup dump
  244.   #else /* ! defined (HAVE_SHM) */
  245. !     LD_LIBRARYN32_PATH=$(ROOT)/usr/lib32 ./temacs -batch -l loadup dump
  246.   #endif /* ! defined (HAVE_SHM) */
  247.   #endif /* ! defined (CANNOT_DUMP) */
  248.   
  249. *** ./lib-src/Makefile.in    Fri Jun 21 01:45:18 1996
  250. --- ../emacs-19.34/./lib-src/Makefile.in    Fri May 15 10:42:41 1998
  251. ***************
  252. *** 88,100 ****
  253.   
  254.   # Things that a user might actually run,
  255.   # which should be installed in bindir.
  256. ! INSTALLABLES = etags ctags emacsclient b2m
  257.   INSTALLABLE_SCRIPTS = rcs-checkin
  258.   
  259.   # Things that Emacs runs internally, or during the build process,
  260.   #  which should not be installed in bindir.
  261.   UTILITIES=  profile digest-doc \
  262. !     sorted-doc movemail cvtmail fakemail yow emacsserver hexl
  263.   
  264.   DONT_INSTALL= test-distrib make-docfile
  265.   
  266. --- 88,100 ----
  267.   
  268.   # Things that a user might actually run,
  269.   # which should be installed in bindir.
  270. ! INSTALLABLES = etags ctags emacsclient b2m gnuclient gnudoit
  271.   INSTALLABLE_SCRIPTS = rcs-checkin
  272.   
  273.   # Things that Emacs runs internally, or during the build process,
  274.   #  which should not be installed in bindir.
  275.   UTILITIES=  profile digest-doc \
  276. !     sorted-doc movemail cvtmail fakemail yow emacsserver hexl gnuserv
  277.   
  278.   DONT_INSTALL= test-distrib make-docfile
  279.   
  280. ***************
  281. *** 374,379 ****
  282. --- 374,394 ----
  283.   
  284.   emacsclient: ${srcdir}/emacsclient.c ../src/config.h
  285.       $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c $(LOADLIBES) -o emacsclient
  286. + /* ange's gnuserv stuff */
  287. + gnuclient: gnuserv.h gnuslib.o gnuclient.c ../src/config.h
  288. +     $(CC) -o gnuclient -I${srcdir}/../src ${ALL_CFLAGS} ${srcdir}/gnuclient.c gnuslib.o $(LOADLIBES)
  289. + gnuserv: gnuserv.h gnuslib.o gnuserv.c ../src/config.h
  290. +     $(CC) -o gnuserv -I${srcdir}/../src ${ALL_CFLAGS} ${srcdir}/gnuserv.c gnuslib.o $(LOADLIBES)
  291. + gnudoit: gnuserv.h gnuslib.o gnudoit.c ../src/config.h
  292. +     $(CC) -o gnudoit -I${srcdir}/../src ${ALL_CFLAGS} ${srcdir}/gnudoit.c gnuslib.o $(LOADLIBES)
  293. + gnuslib.o: gnuserv.h gnuslib.c ../src/config.h
  294. +     $(CC) -c -I${srcdir}/../src ${ALL_CFLAGS} ${srcdir}/gnuslib.c
  295.   
  296.   hexl: ${srcdir}/hexl.c
  297.       $(CC) ${ALL_CFLAGS} ${srcdir}/hexl.c $(LOADLIBES) -o hexl
  298. *** ./lib-src/gnuclient.c    Thu May 21 11:32:03 1998
  299. --- ../emacs-19.34/./lib-src/gnuclient.c    Fri May 15 10:38:26 1998
  300. ***************
  301. *** 0 ****
  302. --- 1,249 ----
  303. + /* -*-C-*-
  304. +  Client code to allow local and remote editing of files by GNU Emacs.
  305. +  This file is part of GNU Emacs. 
  306. +  Copying is permitted under those conditions described by the GNU
  307. +  General Public License.
  308. +  Copyright (C) 1989 Free Software Foundation, Inc.
  309. +  Author: Andy Norman (ange@hplb.hpl.hp.com), based on 
  310. +          'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
  311. +  Please mail bugs and suggestions to the author at the above address.
  312. + */
  313. + static char rcsid [] = "$Header: gnuclient.c,v 1.8 89/07/24 12:46:46 ange Exp $";
  314. + #include "gnuserv.h"
  315. + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
  316. + main ()
  317. + {
  318. +   fprintf (stderr,"Sorry, the Emacs server is only supported on systems that have\n");
  319. +   fprintf (stderr,"Unix Domain sockets, Internet Domain sockets or System V IPC.\n");
  320. +   exit (1);
  321. + } /* main */
  322. + #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
  323. + static char cwd[MAXPATHLEN+2];            /* current working directory when calculated */
  324. + static char *cp = NULL;                /* ptr into valid bit of cwd above */
  325. + /*
  326. +   get_current_working_directory -- return the cwd.
  327. + */
  328. + char *get_current_working_directory()
  329. + {
  330. +   if (cp == NULL) {                /* haven't calculated it yet */
  331. + #ifdef BSD
  332. +     if (getwd(cwd) == 0) {
  333. + #else /* !BSD */
  334. +     if (getcwd(cwd,MAXPATHLEN) == NULL) {
  335. + #endif /* !BSD */
  336. +       perror(progname);
  337. +       fprintf(stderr,"%s: unable to get current working directory\n",progname);
  338. +       exit(1);
  339. +     }; /* if */
  340. +     
  341. +     /* on some systems, cwd can look like '@machine/' ... */
  342. +     /* ignore everything before the first '/' */
  343. +     for (cp = cwd; *cp && *cp != '/'; ++cp)
  344. +       ;                           
  345. +   }; /* if */
  346. +   return cp;
  347. +     
  348. + } /* get_current_working_directory */
  349. + /*
  350. +   filename_expand -- try to convert the given filename into a fully-qualified
  351. +                pathname.
  352. + */
  353. + void filename_expand(fullpath,filename)
  354. +      char *fullpath;                /* returned full pathname */
  355. +      char *filename;                /* filename to expand */
  356. + {
  357. +   int len;
  358. +   fullpath[0] = '\0';
  359. +   
  360. +   if(filename[0] && filename[0] != '/') {    /* relative filename */
  361. +     
  362. +     strcat(fullpath,get_current_working_directory());
  363. +     len = strlen(fullpath);
  364. +      
  365. +     if (len > 0 && fullpath[len-1] == '/')    /* trailing slash already? */
  366. +       ;                        /* yep */
  367. +     else
  368. +       strcat(fullpath,"/");            /* nope, append trailing slash */
  369. +   }; /* if */
  370. +   strcat(fullpath,filename);
  371. + } /* filename_expand */
  372. + main(argc,argv)
  373. +      int argc;
  374. +      char *argv[];
  375. + {
  376. +   int starting_line = 1;            /* line to start editing at */
  377. +   char command[MAXPATHLEN+50];            /* emacs command buffer */
  378. +   char fullpath[MAXPATHLEN+1];            /* full pathname to file */
  379. +   int qflg = 0;                    /* quick edit, don't wait for user to finish */
  380. +   int errflg = 0;                /* option error */
  381. +   int c;                    /* char from getopt */
  382. +   int s;                    /* socket / msqid to server */
  383. + #ifdef INTERNET_DOMAIN_SOCKETS
  384. +   char thishost[HOSTNAMSZ];            /* this hostname */
  385. +   char remotehost[HOSTNAMSZ];            /* remote hostname */
  386. +   char remotepath[MAXPATHLEN+1];        /* remote pathname */
  387. +   int hflg = 0;                    /* hostname given on command line */
  388. +   int rflg = 0;                    /* pathname given on command line */
  389. +   u_short port = 0;                /* port to server */
  390. +   char *ptr;                    /* return from getenv */
  391. + #endif /* INTERNET_DOMAIN_SOCKETS */
  392. + #ifdef SYSV_IPC
  393. +   struct msgbuf *msgp;                /* message */
  394. + #endif /* SYSV_IPC */
  395. +   progname = argv[0];
  396. +   while ((c = getopt(argc, argv,
  397. + #ifdef INTERNET_DOMAIN_SOCKETS
  398. +              "h:p:r:q"
  399. + #else /* !INTERNET_DOMAIN_SOCKETS */
  400. +              "q"
  401. + #endif /* !INTERNET_DOMAIN_SOCKETS */
  402. +              )) != EOF)
  403. +     switch (c) {
  404. +     case 'q':                    /* quick mode specified */
  405. +       qflg++;
  406. +       break;
  407. + #ifdef INTERNET_DOMAIN_SOCKETS
  408. +     case 'h':                    /* server host name specified */
  409. +       strcpy(remotehost,optarg);
  410. +       hflg++;
  411. +       break;
  412. +     case 'r':                    /* remote path from server specifed */
  413. +       strcpy(remotepath,optarg);
  414. +       rflg++;
  415. +       break;
  416. +     case 'p':                    /* port number specified */
  417. +       port = atoi(optarg);
  418. +       break;
  419. + #endif /* INTERNET_DOMAIN_SOCKETS */
  420. +     case '?':
  421. +       errflg++;
  422. +     }; /* switch */
  423. +   if (errflg) {
  424. +     fprintf(stderr,
  425. + #ifdef INTERNET_DOMAIN_SOCKETS
  426. +         "usage: %s [-q] [-h hostname] [-p port] [-r pathname] [[+line] path] ...\n",
  427. + #else /* !INTERNET_DOMAIN_SOCKETS */
  428. +         "usage: %s [-q] [[+line] path] ...\n",
  429. + #endif /* !INTERNET_DOMAIN_SOCKETS */
  430. +         progname);
  431. +     exit (1);
  432. +   }; /* if */
  433. + #ifdef INTERNET_DOMAIN_SOCKETS
  434. +   gethostname(thishost,HOSTNAMSZ);
  435. +   if (!hflg) {                    /* attempt to find the server host */
  436. +     if((ptr=getenv("GNU_HOST")) != NULL)    /* user specified a host */
  437. +       strcpy(remotehost,ptr);
  438. +     else                    /* use this host by default */
  439. +       strcpy(remotehost,thishost);
  440. +   }; /* if */
  441. +   if(!rflg) {                    /* attempt to generate a path to this machine */
  442. +     if((ptr=getenv("GNU_NODE")) != NULL)    /* user specified a path */
  443. +       strcpy(remotepath,ptr);
  444. + #if defined(hp9000s300) || defined(hp9000s800)
  445. +     else if (strcmp(thishost,remotehost)) {    /* try /net/thishost */
  446. +       strcpy(remotepath,"/net/");         /* (this fails using internet addresses) */
  447. +       strcat(remotepath,thishost);
  448. +     }
  449. + #endif
  450. +     else                    /* same machines, no need for path */
  451. +       remotepath[0] = '\0';            /* default is the empty path */
  452. +   }; /* if */
  453. +   if (port == 0 && (ptr=getenv("GNU_PORT")) != NULL)
  454. +     port = atoi(ptr);
  455. + #ifdef UNIX_DOMAIN_SOCKETS
  456. +   if (!strcmp(remotehost,"unix"))
  457. +     s = connect_to_unix_server();
  458. +   else
  459. + #endif /* UNIX_DOMAIN_SOCKETS */
  460. +     s = connect_to_internet_server(remotehost,port);
  461. + #else  /* !INTERNET_DOMAIN_SOCKETS */
  462. + #ifdef UNIX_DOMAIN_SOCKETS
  463. +   s = connect_to_unix_server();
  464. + #endif /* UNIX_DOMAIN_SOCKETS */
  465. + #ifdef SYSV_IPC
  466. +   if ((msgp = (struct msgbuf *) malloc(sizeof *msgp + BUFSIZ)) == NULL) {
  467. +     fprintf(stderr,"%s: not enough memory for message buffer\n",progname);
  468. +     exit(1);
  469. +   }; /* if */
  470. +   msgp->mtext[0] = '\0';            /* ready for later strcats */
  471. +   s = connect_to_ipc_server();
  472. + #endif /* SYSV_IPC */
  473. + #endif /* !INTERNET_DOMAIN_SOCKETS */
  474. +   if (qflg) {
  475. +     send_string(s,"(server-edit-files-quickly '(");
  476. +   }
  477. +   else {
  478. +     send_string(s,"(server-edit-files '(");
  479. +   };
  480. +   for (; optind < argc; optind++) {
  481. +     if (*argv[optind] == '+')
  482. +       starting_line = atoi(argv[optind]);
  483. +     else {
  484. +       filename_expand(fullpath,argv[optind]);
  485. +       sprintf(command,"(%d . \"%s%s\")",starting_line,
  486. + #ifdef INTERNET_DOMAIN_SOCKETS
  487. +           remotepath,
  488. + #else /* !INTERNET_DOMAIN_SOCKETS */
  489. +           "",
  490. + #endif
  491. +           fullpath);
  492. +       send_string(s,command);
  493. +       starting_line = 1;
  494. +     }; /* else */
  495. +   }; /* for */
  496. +   send_string(s,"))");
  497. + #ifdef SYSV_IPC
  498. +   disconnect_from_ipc_server(s,msgp,FALSE);
  499. + #else /* !SYSV_IPC */
  500. +   disconnect_from_server(s,FALSE);
  501. + #endif /* !SYSV_IPC */
  502. +   exit(0);
  503. + } /* main */
  504. + #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
  505. *** ./lib-src/gnuserv.h    Thu May 21 11:32:03 1998
  506. --- ../emacs-19.34/./lib-src/gnuserv.h    Fri May 15 10:38:52 1998
  507. ***************
  508. *** 0 ****
  509. --- 1,102 ----
  510. + /* -*-C-*-
  511. +  Header file for the GNU Emacs server and client C code.
  512. +  This file is part of GNU Emacs.
  513. +  Copying is permitted under those conditions described by the GNU
  514. +  General Public License.
  515. +  Copyright (C) 1989 Free Software Foundation, Inc.
  516. +  Author: Andy Norman (ange@hplb.hpl.hp.com), based on 
  517. +          'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
  518. +          Emacs distribution.
  519. +  Please mail bugs and suggestions to the author at the above address.
  520. + */
  521. + static char header_rcsid [] = "$Header: gnuserv.h,v 1.9 90/01/31 10:37:41 ange Exp $";
  522. + #define NO_SHORTNAMES
  523. + #define PATCHLEVEL 2
  524. + #include "../src/config.h"
  525. + #undef read
  526. + #undef write
  527. + #undef open
  528. + #undef close
  529. + /* Define the communication method between server and clients */
  530. + #define INTERNET_DOMAIN_SOCKETS
  531. + #define UNIX_DOMAIN_SOCKETS
  532. + /* #define SYSV_IPC */
  533. + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
  534. + #ifdef HAVE_SYSVIPC
  535. + #define SYSV_IPC        /* SYSV systems use SYSV IPC by default */
  536. + #endif /* HAVE_SYSVIPC */
  537. + #ifdef BSD
  538. + #define UNIX_DOMAIN_SOCKETS    /* BSD systems use Unix Domain sockets by default */
  539. + #endif /* BSD */
  540. + #endif /* No communication method pre-defined */
  541. + #include <sys/types.h>
  542. + #include <sys/param.h>
  543. + #include <stdio.h>
  544. + #include <signal.h>
  545. + #ifdef SYSV_IPC
  546. + #include <sys/ipc.h>
  547. + #include <sys/msg.h>
  548. + #define send_string(s,str) \
  549. +   if (strlen(msgp->mtext) + strlen(str) < BUFSIZ) \
  550. +      strcat(msgp->mtext,str); \
  551. +   else \
  552. +   { \
  553. +     fprintf(stderr,"%s: not enough message buffer space\n",progname); \
  554. +      exit(1); \
  555. +   } \
  556. + #endif /* SYSV_IPC */
  557. + #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
  558. + #include <sys/socket.h>
  559. + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
  560. + #ifdef INTERNET_DOMAIN_SOCKETS
  561. + #include <netinet/in.h>
  562. + #include <netdb.h>
  563. + #define TABLE_SIZE 101        /* The number of entries in the hash table */
  564. + #define HASH(host) host        /* Rather simplistic hash function */
  565. + #define DEFAULT_PORT 21490    /* default port number to use */
  566. + #endif /* INTERNET_DOMAIN_SOCKETS */
  567. + #ifdef UNIX_DOMAIN_SOCKETS
  568. + #include <sys/un.h>
  569. + #endif /* UNIX_DOMAIN_SOCKETS */
  570. + #define HOSTNAMSZ 255        /* max size of a hostname */
  571. + #define REPLYSIZ 300        /* max size of reply from server to client */
  572. + #define FALSE 0
  573. + #define TRUE 1
  574. + extern char *getenv();
  575. + extern char *optarg;
  576. + extern int optind;
  577. + extern char *progname;
  578. + #ifndef BSD
  579. + extern char *getcwd();
  580. + #endif
  581. + #define max2(x,y) (((x) > (y)) ? (x) : (y))
  582. + #ifndef _NFILE            /* rough guess at maximum number of open files */
  583. + #define _NFILE 20
  584. + #endif
  585. *** ./lib-src/gnuserv.c    Thu May 21 11:32:03 1998
  586. --- ../emacs-19.34/./lib-src/gnuserv.c    Fri May 15 10:38:48 1998
  587. ***************
  588. *** 0 ****
  589. --- 1,542 ----
  590. + /* -*-C-*-
  591. +  Server code for handling requests from clients and forwarding them
  592. +  on to the GNU Emacs process.
  593. +  This file is part of GNU Emacs.
  594. +  Copying is permitted under those conditions described by the GNU
  595. +  General Public License.
  596. +  Copyright (C) 1989 Free Software Foundation, Inc.
  597. +  Author: Andy Norman (ange@hplb.hpl.hp.com), based on 'etc/server.c'
  598. +          from the 18.52 GNU Emacs distribution.
  599. +  Please mail bugs and suggestions to the author at the above address.
  600. + */
  601. + static char rcsid [] = "$Header: gnuserv.c,v 1.8 89/09/28 12:47:01 ange Exp $";
  602. + #include "gnuserv.h"
  603. + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
  604. + main ()
  605. + {
  606. +   fprintf (stderr,"Sorry, the Emacs server is only supported on systems that have\n");
  607. +   fprintf (stderr,"Unix Domain sockets, Internet Domain sockets or System V IPC\n");
  608. +   exit (1);
  609. + } /* main */
  610. + #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
  611. + #ifdef SYSV_IPC
  612. + int ipc_qid = 0;        /* ipc message queue id */
  613. + int ipc_wpid = 0;        /* watchdog task pid */
  614. + /*
  615. +   ipc_exit -- clean up the queue id and queue, then kill the watchdog task
  616. +               if it exists. exit with the given status.
  617. + */
  618. + void ipc_exit(stat)
  619. +      int stat;
  620. + {
  621. +   msgctl(ipc_qid,IPC_RMID,0);
  622. +   
  623. +   if (ipc_wpid != 0)
  624. +     kill(ipc_wpid,SIGKILL);
  625. +   exit(stat);
  626. + } /* ipc_exit */
  627. + /*
  628. +   ipc_handle_signal -- catch the signal given and clean up.
  629. + */
  630. + void ipc_handle_signal(sig)
  631. +      int sig;
  632. + {
  633. +   ipc_exit(0);
  634. + } /* ipc_handle_signal */
  635. + /* 
  636. +   ipc_spawn_watchdog -- spawn a watchdog task to clean up the message queue should the
  637. +             server process die.
  638. + */
  639. + int ipc_spawn_watchdog()
  640. + {
  641. +   if ((ipc_wpid = fork()) == 0) { /* child process */
  642. +     int ppid = getppid();    /* parent's process id */
  643. +     setpgrp();            /* gnu kills process group on exit */
  644. +     
  645. +     while (1) {
  646. +       if (kill(ppid,0) < 0) {    /* ppid is no longer valid, parent may have died */
  647. +     ipc_exit(0);
  648. +       }; /* if */
  649. +       sleep(10);        /* have another go later */
  650. +     }; /* while */
  651. +   }; /* if */
  652. + } /* ipc_spawn_watchdog */
  653. + /*
  654. +   ipc_init -- initialize server, setting the global msqid that can be listened on.
  655. + */
  656. + void ipc_init(msgpp)
  657. +      struct msgbuf **msgpp;
  658. + {
  659. +   key_t key;            /* messge key */
  660. +   char buf[BUFSIZ];        /* pathname for key */
  661. +   int p;            /* child process id */
  662. +   sprintf(buf,"/tmp/gsrv%d",geteuid());
  663. +   creat(buf,0600);
  664. +   key = ftok(buf,1);
  665. +   if ((ipc_qid = msgget(key,0600|IPC_CREAT)) == -1) {
  666. +     perror(progname);
  667. +     fprintf(stderr,"%s: unable to create msg queue\n",progname);
  668. +     ipc_exit(1);
  669. +   }; /* if */
  670. +   ipc_spawn_watchdog();
  671. +   signal(SIGTERM,ipc_handle_signal);
  672. +   signal(SIGINT,ipc_handle_signal);
  673. +   if ((*msgpp = (struct msgbuf *) malloc(sizeof **msgpp + BUFSIZ)) == NULL) {
  674. +     fprintf(stderr,"%s: unable to allocate space for message buffer\n",progname);
  675. +     ipc_exit(1);
  676. +   }; /* if */
  677. + } /* ipc_init */
  678. + /*
  679. +   handle_ipc_request -- accept a request from a client, pass the request on
  680. +               to the GNU Emacs process, then wait for its reply and
  681. +             pass that on to the client.
  682. + */
  683. + void handle_ipc_request(msgp)
  684. +      struct msgbuf *msgp;    /* message buffer */
  685. + {
  686. +   struct msqid_ds msg_st;    /* message status */
  687. +   char buf[BUFSIZ];
  688. +   int len;            /* length of message / read */
  689. +   int junk;            /* junk value */
  690. +   if ((len = msgrcv(ipc_qid,msgp,BUFSIZ-1,1,0)) < 0) {
  691. +     perror(progname);
  692. +     fprintf(stderr,"%s: unable to receive\n",progname);
  693. +     ipc_exit(1);
  694. +   }; /* if */
  695. +   msgctl(ipc_qid,IPC_STAT,&msg_st);
  696. +   strncpy(buf,msgp->mtext,len);
  697. +   buf[len] = '\0';        /* terminate */
  698. +   
  699. +   printf("%d %s",ipc_qid,buf);
  700. +   fflush(stdout);
  701. +   if ((len = read(0,buf,BUFSIZ)) < 0) {
  702. +     perror(progname);
  703. +     fprintf(stderr,"%s: unable to read\n",progname);
  704. +     ipc_exit(1);
  705. +   }; /* if */
  706. +       
  707. +   /* parse the response from gnu */
  708. +   msgp->mtext[0] = '\0';
  709. +   sscanf(buf,"%d:%[^\n]\n",&junk,msgp->mtext);
  710. +   /* Send a response back to the client. */
  711. +   msgp->mtype = msg_st.msg_lspid;
  712. +   msgsnd(ipc_qid,msgp,strlen(msgp->mtext)+1,0);
  713. + } /* handle_ipc_request */
  714. + #endif /* SYSV_IPC */
  715. + #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
  716. + /*
  717. +   echo_request -- read request from a given socket descriptor, and send the information
  718. +                   to stdout (the gnu process).
  719. + */
  720. + void echo_request(s)
  721. + int s;                /* socket */
  722. + {
  723. +   char buf[BUFSIZ];
  724. +   int len;
  725. +   printf("%d ",s);
  726. +   
  727. +   /* read until we get a newline or no characters */
  728. +   while ((len = recv(s,buf,BUFSIZ,0)) > 0) {
  729. +     buf[len] = '\0';
  730. +     printf("%s",buf);
  731. +     if (buf[len-1] == '\n')
  732. +       break;            /* end of message */
  733. +   }; /* while */
  734. +   if (len < 0) {
  735. +     perror(progname);
  736. +     fprintf(stderr,"%s: unable to recv\n",progname);
  737. +     exit(1);
  738. +   }; /* if */
  739. +   
  740. + } /* echo_request */
  741. + /*
  742. +   handle_response -- accept a response from stdin (the gnu process) and pass the
  743. +                      information on to the relevant client.
  744. + */
  745. + void handle_response()
  746. + {
  747. +   char buf[BUFSIZ];
  748. +   char response[BUFSIZ];
  749. +   int s;
  750. +   int len;
  751. +   if ((len = read(0,buf,BUFSIZ)) < 0) {
  752. +     perror(progname);
  753. +     fprintf(stderr,"%s: unable to read\n",progname);
  754. +     exit(1);
  755. +   }; /* if */
  756. +       
  757. +   /* parse the response from gnu */
  758. +   response[0] = '\0';
  759. +   sscanf(buf,"%d:%[^\n]\n", &s, response);
  760. +   /* Send a response back to the client. */
  761. +   send_string(s,response);
  762. +   close(s);
  763. + } /* handle_response */
  764. + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
  765. + #ifdef INTERNET_DOMAIN_SOCKETS
  766. + struct entry {
  767. +   u_long host_addr;
  768. +   struct entry *next;
  769. + };
  770. + struct entry *permitted_hosts[TABLE_SIZE];
  771. + /*
  772. +   permitted -- return whether a given host is allowed to connect to the server.
  773. + */
  774. + int permitted(host_addr)
  775. +      u_long host_addr;
  776. + {
  777. +   int key;
  778. +   struct entry *entry;
  779. +   
  780. +   /* First find the hash key */
  781. +   key = HASH(host_addr) % TABLE_SIZE;
  782. +   
  783. +   /* Now check the chain for that hash key */
  784. +   for(entry=permitted_hosts[key]; entry != NULL; entry=entry->next)
  785. +     if (host_addr == entry->host_addr) 
  786. +       return(TRUE);
  787. +   return(FALSE);
  788. + } /* permitted */
  789. + /* 
  790. +   add_host -- add the given host to the list of permitted hosts, provided it isn't
  791. +               already there.
  792. + */    
  793. + void add_host(host_addr)
  794. +      u_long host_addr;
  795. + {
  796. +   int key;
  797. +   struct entry *new_entry;
  798. +   
  799. +   if (!permitted(host_addr)) {
  800. +     if ((new_entry = (struct entry *) malloc(sizeof(struct entry))) == NULL) {
  801. +       fprintf(stderr,"%s: unable to malloc space for permitted host entry\n",
  802. +           progname);
  803. +       exit(1);
  804. +     }; /* if */
  805. +     new_entry->host_addr = host_addr;
  806. +     key = HASH(host_addr) % TABLE_SIZE;
  807. +     new_entry->next = permitted_hosts[key];
  808. +     permitted_hosts[key] = new_entry;
  809. +   }; /* if */
  810. + } /* add_host */
  811. + /*
  812. +   setup_table -- initialise the table of hosts allowed to contact the server. 
  813. +                  Put in the local machine, and, if a security file is specifed,
  814. +                  add each host that is named in the file.
  815. + */
  816. + void setup_table()
  817. + {
  818. +   FILE *host_file;
  819. +   char *file_name;
  820. +   char hostname[HOSTNAMSZ];
  821. +   u_long host_addr;
  822. +   int i;
  823. +   
  824. +   /* Make sure every entry is null */
  825. +   for (i=0; i<TABLE_SIZE; i++)
  826. +     permitted_hosts[i] = NULL;
  827. +   gethostname(hostname,HOSTNAMSZ);
  828. +   if ((host_addr = internet_addr(hostname)) == -1) {
  829. +     fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP", 
  830. +         progname,hostname);
  831. +     exit(1);
  832. +   }; /* if */
  833. +   add_host(host_addr);                    /* add local host */
  834. +   if (((file_name = getenv("GNU_SECURE")) != NULL &&    /* security file  */
  835. +        (host_file = fopen(file_name,"r")) != NULL)) {    /* opened ok */
  836. +     while ((fscanf(host_file,"%s",hostname) != EOF))    /* find a host */
  837. +       if ((host_addr = internet_addr(hostname)) != -1)    /* get its internet addr */
  838. +     add_host(host_addr);                /* add the addr */
  839. +     fclose(host_file);
  840. +   }; /* if */
  841. + } /* setup_table */
  842. + /*
  843. +   internet_init -- initialize server, returning an internet socket that can
  844. +                     be listened on.
  845. + */
  846. + int internet_init()
  847. + {
  848. +   int ls;            /* socket descriptor */
  849. +   struct servent *sp;        /* pointer to service information */
  850. +   struct sockaddr_in server;    /* for local socket address */
  851. +   char *ptr;            /* ptr to return from getenv */
  852. +   setup_table();
  853. +   /* clear out address structure */
  854. +   bzero((char *)&server,sizeof(struct sockaddr_in));
  855. +   
  856. +   /* Set up address structure for the listen socket. */
  857. +   server.sin_family = AF_INET;
  858. +   server.sin_addr.s_addr = INADDR_ANY;
  859. +   /* Find the information for the gnu server
  860. +    * in order to get the needed port number.
  861. +    */
  862. +   if ((ptr=getenv("GNU_PORT")) != NULL)
  863. +     server.sin_port = htons(atoi(ptr));
  864. +   else if ((sp = getservbyname ("gnuserv", "tcp")) == NULL)
  865. +     server.sin_port = htons(DEFAULT_PORT+getuid());
  866. +   else
  867. +     server.sin_port = sp->s_port;
  868. +   
  869. +   /* Create the listen socket. */
  870. +   if ((ls = socket (AF_INET,SOCK_STREAM, 0)) == -1) {
  871. +     perror(progname);
  872. +     fprintf(stderr,"%s: unable to create socket\n",progname);
  873. +     exit(1);
  874. +   }; /* if */
  875. +   
  876. +   /* Bind the listen address to the socket. */
  877. +   if (bind(ls,&server,sizeof(struct sockaddr_in)) == -1) {
  878. +     perror(progname);
  879. +     fprintf(stderr,"%s: unable to bind socket\n",progname);
  880. +     exit(1);
  881. +   }; /* if */
  882. +   /* Initiate the listen on the socket so remote users
  883. +    * can connect. 
  884. +    */
  885. +   if (listen(ls,20) == -1) {
  886. +     perror(progname);
  887. +     fprintf(stderr,"%s: unable to listen\n",progname);
  888. +     exit(1);
  889. +   }; /* if */
  890. +   return(ls);
  891. + } /* internet_init */
  892. + /*
  893. +   handle_internet_request -- accept a request from a client and send the information
  894. +                              to stdout (the gnu process).
  895. + */
  896. + void handle_internet_request(ls)
  897. + int ls;                /* listen socket */
  898. + {
  899. +   int s;
  900. +   int addrlen = sizeof(struct sockaddr_in);
  901. +   struct sockaddr_in peer;    /* for peer socket address */
  902. +   bzero((char *)&peer,sizeof(struct sockaddr_in));
  903. +   if ((s = accept(ls,&peer,&addrlen)) == -1) {
  904. +     perror(progname);
  905. +     fprintf(stderr,"%s: unable to accept\n",progname);
  906. +     exit(1);
  907. +   }; /* if */
  908. +     
  909. +   /* Check that access is allowed - if not return crud to the client */
  910. +   if (!permitted(peer.sin_addr.s_addr)) {
  911. +     send_string(s,"gnudoit: Connection refused\ngnudoit: unable to connect to remote");
  912. +     close(s);
  913. +     return;
  914. +   }; /* if */
  915. +   echo_request(s);
  916. +   
  917. + } /* handle_internet_request */
  918. + #endif /* INTERNET_DOMAIN_SOCKETS */
  919. + #ifdef UNIX_DOMAIN_SOCKETS
  920. + /*
  921. +   unix_init -- initialize server, returning an unix-domain socket that can
  922. +                be listened on.
  923. + */
  924. + int unix_init()
  925. + {
  926. +   int ls;            /* socket descriptor */
  927. +   struct sockaddr_un server;     /* unix socket address */
  928. +   if ((ls = socket(AF_UNIX,SOCK_STREAM, 0)) < 0) {
  929. +     perror(progname);
  930. +     fprintf(stderr,"%s: unable to create socket\n",progname);
  931. +     exit(1);
  932. +   }; /* if */
  933. +   /* Set up address structure for the listen socket. */
  934. +   sprintf(server.sun_path,"/tmp/gsrv%d",geteuid());
  935. +   unlink(server.sun_path);    /* remove old file if it exists */
  936. +   server.sun_family = AF_UNIX;
  937. +  
  938. +   if (bind(ls,&server,strlen(server.sun_path)+2) < 0) {
  939. +     perror(progname);
  940. +     fprintf(stderr,"%s: unable to bind socket\n",progname);
  941. +     exit(1);
  942. +   }; /* if */
  943. +   chmod(server.sun_path,0700);    /* only this user can send commands */
  944. +   if (listen(ls,20) < 0) {
  945. +     perror(progname);
  946. +     fprintf(stderr,"%s: unable to listen\n",progname);
  947. +     exit(1);
  948. +   }; /* if */
  949. +   signal(SIGPIPE,SIG_IGN);    /* in case user kills client */
  950. +   return(ls);
  951. + } /* unix_init */
  952. + /*
  953. +   handle_unix_request -- accept a request from a client and send the information
  954. +                          to stdout (the gnu process).
  955. + */
  956. + void handle_unix_request(ls)
  957. + int ls;                /* listen socket */
  958. + {
  959. +   int s;
  960. +   int len = sizeof(struct sockaddr_un);
  961. +   struct sockaddr_un server;     /* for unix socket address */
  962. +   server.sun_family = AF_UNIX;
  963. +   if ((s = accept(ls,&server,&len)) < 0) {
  964. +     perror(progname);
  965. +     fprintf(stderr,"%s: unable to accept\n",progname);
  966. +   }; /* if */
  967. +   echo_request(s);
  968. +   
  969. + } /* handle_unix_request */
  970. + #endif /* UNIX_DOMAIN_SOCKETS */
  971. + main(argc,argv)
  972. +      int argc;
  973. +      char *argv[];
  974. + {
  975. +   int ils = -1;            /* internet domain listen socket */
  976. +   int uls = -1;            /* unix domain listen socket */
  977. +   int chan;            /* temporary channel number */
  978. + #ifdef SYSV_IPC
  979. +   struct msgbuf *msgp;        /* message buffer */
  980. + #endif /* SYSV_IPC */
  981. +   progname = argv[0];
  982. +   for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */
  983. +     ;
  984. + #ifdef SYSV_IPC
  985. +   ipc_init(&msgp);        /* get a msqid to listen on, and a message buffer */
  986. + #endif /* SYSV_IPC */
  987. + #ifdef INTERNET_DOMAIN_SOCKETS
  988. +   ils = internet_init();    /* get a internet domain socket to listen on */
  989. + #endif /* INTERNET_DOMAIN_SOCKETS */
  990. + #ifdef UNIX_DOMAIN_SOCKETS
  991. +   uls = unix_init();        /* get a unix domain socket to listen on */
  992. + #endif /* UNIX_DOMAIN_SOCKETS */
  993. +   while (1) {
  994. + #ifdef SYSV_IPC
  995. +     handle_ipc_request(msgp);
  996. + #else /* NOT SYSV_IPC */
  997. +     int rmask = 1 
  998. + #ifdef UNIX_DOMAIN_SOCKETS
  999. +       + (1 << uls) 
  1000. + #endif /* UNIX_DOMAIN_SOCKETS */
  1001. + #ifdef INTERNET_DOMAIN_SOCKETS
  1002. +       + (1 << ils)
  1003. + #endif /* INTERNET_DOMAIN_SOCKETS */
  1004. +       ;
  1005. +     
  1006. +     if (select(max2(uls,ils) + 1,&rmask,0,0,0) < 0) {
  1007. +       perror(progname);
  1008. +       fprintf(stderr,"%s: unable to select\n",progname);
  1009. +       exit(1);
  1010. +     }; /* if */
  1011. + #ifdef UNIX_DOMAIN_SOCKETS    
  1012. +     if (rmask & (1 << uls))    /* from unix domain socket (client process) */
  1013. +       handle_unix_request(uls);
  1014. + #endif /* UNIX_DOMAIN_SOCKETS */
  1015. + #ifdef INTERNET_DOMAIN_SOCKETS
  1016. +     if (rmask & (1 << ils))    /* from internet domain socket (client process) */
  1017. +       handle_internet_request(ils);
  1018. + #endif /* INTERNET_DOMAIN_SOCKETS */
  1019. +     if (rmask & 1)         /* from stdin (gnu process) */
  1020. +       handle_response();
  1021. + #endif /* NOT SYSV_IPC */
  1022. +   }; /* while */
  1023. + } /* main */
  1024. + #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
  1025. *** ./lib-src/gnudoit.c    Thu May 21 11:32:03 1998
  1026. --- ../emacs-19.34/./lib-src/gnudoit.c    Fri May 15 10:38:38 1998
  1027. ***************
  1028. *** 0 ****
  1029. --- 1,139 ----
  1030. + /* -*-C-*-
  1031. +  Client code to locally and remotely evaluate lisp forms using GNU Emacs.
  1032. +  This file is part of GNU Emacs.
  1033. +  Copying is permitted under those conditions described by the GNU
  1034. +  General Public License.
  1035. +  Copyright (C) 1989 Free Software Foundation, Inc.
  1036. +  Author: Andy Norman (ange@hplb.hpl.hp.com).
  1037. +  Please mail bugs and suggestions to the author at the above address.
  1038. + */
  1039. + static char rcsid [] = "$Header: gnudoit.c,v 1.5 89/07/24 12:47:53 ange Exp $";
  1040. + #include "gnuserv.h"
  1041. + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
  1042. + main ()
  1043. + {
  1044. +   fprintf (stderr,"Sorry, the Emacs server is only supported on systems that have\n");
  1045. +   fprintf (stderr,"Unix Domain sockets, Internet Domain sockets or System V IPC.\n");
  1046. +   exit (1);
  1047. + } /* main */
  1048. + #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
  1049. + main(argc,argv)
  1050. +      int argc;
  1051. +      char *argv[];
  1052. + {
  1053. +   int starting_line = 1;            /* line to start editing at */
  1054. +   int qflg = 0;                    /* don't wait around for gnu emacs to eval cmd */
  1055. +   int errflg = 0;                /* option error */
  1056. +   int c;                    /* char from getopt */
  1057. +   int s;                    /* socket / msqid to server */
  1058. + #ifdef INTERNET_DOMAIN_SOCKETS
  1059. +   char remotehost[HOSTNAMSZ];            /* remote hostname */
  1060. +   int hflg = 0;                    /* hostname given on command line */
  1061. +   u_short port = 0;                /* port number */
  1062. +   char *ptr;                    /* return from getenv */
  1063. + #endif /* INTERNET_DOMAIN_SOCKETS */
  1064. + #ifdef SYSV_IPC
  1065. +   struct msgbuf *msgp;                /* message */
  1066. + #endif /* SYSV_IPC */
  1067. +   progname = argv[0];
  1068. +   while ((c = getopt(argc, argv,
  1069. + #ifdef INTERNET_DOMAIN_SOCKETS
  1070. +              "qh:p:"
  1071. + #else /* !INTERNET_DOMAIN_SOCKETS */
  1072. +              "q"
  1073. + #endif /* !INTERNET_DOMAIN_SOCKETS */
  1074. +              )) != EOF)
  1075. +     switch (c) {
  1076. + #ifdef INTERNET_DOMAIN_SOCKETS
  1077. +     case 'h':                    /* host name specified */
  1078. +       strcpy(remotehost,optarg);
  1079. +       hflg++;
  1080. +       break;
  1081. +     case 'p':                    /* port number specified */
  1082. +       port = atoi(optarg);
  1083. +       break;
  1084. + #endif /* INTERNET_DOMAIN_SOCKETS */
  1085. +     case 'q':                    /* quick mode specified */
  1086. +       qflg++;
  1087. +       break;
  1088. +     case '?':
  1089. +       errflg++;
  1090. +     }; /* switch */
  1091. +   if (errflg) {
  1092. +     fprintf(stderr,
  1093. + #ifdef INTERNET_DOMAIN_SOCKETS
  1094. +         "usage: %s [-q] [-h hostname] [-p port] [sexpr]...\n",
  1095. + #else /* !INTERNET_DOMAIN_SOCKETS */
  1096. +         "usage: %s [-q] [sexpr]...\n",
  1097. + #endif /* !INTERNET_DOMAIN_SOCKETS */
  1098. +         progname);
  1099. +     exit (1);
  1100. +   }; /* if */
  1101. + #ifdef INTERNET_DOMAIN_SOCKETS
  1102. +   if (!hflg) {
  1103. +     if((ptr=getenv("GNU_HOST")) != NULL)
  1104. +       strcpy(remotehost,ptr);
  1105. +     else
  1106. +       gethostname(remotehost,HOSTNAMSZ);    /* use this host by default */
  1107. +   }; /* if */
  1108. +   if (port == 0 && (ptr=getenv("GNU_PORT")) != NULL)
  1109. +       port = atoi(ptr);
  1110. + #ifdef UNIX_DOMAIN_SOCKETS
  1111. +   if (!strcmp(remotehost,"unix"))
  1112. +     s = connect_to_unix_server();
  1113. +   else
  1114. + #endif /* UNIX_DOMAIN_SOCKETS */
  1115. +     s = connect_to_internet_server(remotehost,port);
  1116. + #else /* !INTERNET_DOMAIN_SOCKETS */
  1117. + #ifdef UNIX_DOMAIN_SOCKETS
  1118. +   s = connect_to_unix_server();
  1119. + #endif /* UNIX_DOMAIN_SOCKETS */
  1120. + #ifdef SYSV_IPC
  1121. +   if ((msgp = (struct msgbuf *) malloc(sizeof *msgp + BUFSIZ)) == NULL) {
  1122. +     fprintf(stderr,"%s: not enough memory for message buffer\n",progname);
  1123. +     exit(1);
  1124. +   }; /* if */
  1125. +   msgp->mtext[0] = '\0';            /* ready for later strcats */
  1126. +   s = connect_to_ipc_server();
  1127. + #endif /* SYSV_IPC */
  1128. + #endif /* !INTERNET_DOMAIN_SOCKETS */
  1129. +   if (qflg) {
  1130. +     send_string(s,"(server-eval-quickly '(progn ");
  1131. +   }
  1132. +   else {
  1133. +     send_string(s,"(server-eval '(progn ");
  1134. +   };
  1135. +   for (; optind < argc; optind++)
  1136. +     send_string(s,argv[optind]);
  1137. +   send_string(s,"))");
  1138. + #ifdef SYSV_IPC
  1139. +   disconnect_from_ipc_server(s,msgp,!qflg);
  1140. + #else /* !SYSV_IPC */
  1141. +   disconnect_from_server(s,!qflg);
  1142. + #endif /* !SYSV_IPC */
  1143. +   exit(0);
  1144. + } /* main */
  1145. + #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
  1146. *** ./lib-src/gnuslib.c    Thu May 21 11:32:03 1998
  1147. --- ../emacs-19.34/./lib-src/gnuslib.c    Fri May 15 10:39:05 1998
  1148. ***************
  1149. *** 0 ****
  1150. --- 1,247 ----
  1151. + /* -*-C-*-
  1152. +  Common library code for the GNU Emacs server and client.
  1153. +  This file is part of GNU Emacs.
  1154. +  Copying is permitted under those conditions described by the GNU
  1155. +  General Public License.
  1156. +  Copyright (C) 1989 Free Software Foundation, Inc.
  1157. +  Author: Andy Norman (ange@hplb.hpl.hp.com), based on 
  1158. +          'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
  1159. +          Emacs distribution.
  1160. +  Please mail bugs and suggestions to the author at the above address.
  1161. + */
  1162. + static char rcsid [] = "$Header: gnuslib.c,v 1.6 89/09/28 12:47:34 ange Exp $";
  1163. + #include "gnuserv.h"
  1164. + char *progname = NULL;
  1165. + #ifdef SYSV_IPC
  1166. + /*
  1167. +   connect_to_ipc_server -- establish connection with server process via SYSV IPC
  1168. +                  Returns msqid for server if successful.
  1169. + */
  1170. + int connect_to_ipc_server()
  1171. + {
  1172. +   int s;            /* connected msqid */
  1173. +   key_t key;            /* message key */
  1174. +   char buf[BUFSIZ];        /* buffer for filename */
  1175. +   sprintf(buf,"/tmp/gsrv%d",geteuid());
  1176. +   creat(buf,0600);
  1177. +   key = ftok(buf,1);
  1178. +   if ((s = msgget(key,0600)) == -1) {
  1179. +     perror(progname);
  1180. +     fprintf(stderr,"%s: unable to access msg queue\n",progname);
  1181. +     exit(1);
  1182. +   }; /* if */
  1183. +   return(s);
  1184. + } /* connect_to_ipc_server */
  1185. + /*
  1186. +   disconnect_from_ipc_server -- inform the server that sending has finished,
  1187. +                                 and wait for its reply.
  1188. + */
  1189. + void disconnect_from_ipc_server(s,msgp,echo)
  1190. +      int s;
  1191. +      struct msgbuf *msgp;
  1192. +      int echo;
  1193. + {
  1194. +   int len;            /* length of received message */
  1195. +   send_string(s,"\n");        /* newline terminates this message */
  1196. +   msgp->mtype = 1;
  1197. +   if(msgsnd(s,msgp,strlen(msgp->mtext)+1,0) < 0) {
  1198. +     perror(progname);
  1199. +     fprintf(stderr,"%s: unable to send message to server\n",progname);
  1200. +     exit(1);
  1201. +   }; /* if */
  1202. +   
  1203. +   if((len = msgrcv(s,msgp,BUFSIZ,getpid(),0)) < 0) {
  1204. +     perror(progname);
  1205. +     fprintf(stderr,"%s: unable to receive message from server\n",progname);
  1206. +     exit(1);
  1207. +   }; /* if */
  1208. +   if (echo) {
  1209. +     msgp->mtext[len] = '\0';    /* string terminate message */
  1210. +     printf("%s\n",msgp->mtext);
  1211. +   }; /* if */
  1212. + } /* disconnect_from_ipc_server */  
  1213. + #endif SYSV_IPC
  1214. + #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
  1215. + /*
  1216. +   send_string -- send string to socket.
  1217. + */
  1218. + void send_string(s,msg)
  1219. +      int s;
  1220. +      char *msg;
  1221. + {
  1222. +   if (send(s,msg,strlen(msg),0) < 0) {
  1223. +     perror(progname);
  1224. +     fprintf(stderr,"%s: unable to send\n",progname);
  1225. +     exit(1);
  1226. +   }; /* if */ 
  1227. +   
  1228. + } /* send_string */
  1229. + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
  1230. + #ifdef UNIX_DOMAIN_SOCKETS
  1231. + /*
  1232. +   connect_to_unix_server -- establish connection with server process via a unix-
  1233. +                   domain socket. Returns socket descriptor for server
  1234. +                 if successful.
  1235. + */
  1236. + int connect_to_unix_server()
  1237. + {
  1238. +   int s;            /* connected socket descriptor */
  1239. +   struct sockaddr_un server;     /* for unix connections */
  1240. +   if ((s = socket(AF_UNIX,SOCK_STREAM,0)) < 0) {
  1241. +     perror(progname);
  1242. +     fprintf(stderr,"%s: unable to create socket\n",progname);
  1243. +     exit(1);
  1244. +   }; /* if */
  1245. +   
  1246. +   server.sun_family = AF_UNIX;
  1247. +   sprintf(server.sun_path,"/tmp/gsrv%d",geteuid());
  1248. +   if (connect(s,&server,strlen(server.sun_path)+2) < 0) {
  1249. +     perror(progname);
  1250. +     fprintf(stderr,"%s: unable to connect to local\n",progname);
  1251. +     exit(1);
  1252. +   }; /* if */
  1253. +   return(s);
  1254. + } /* connect_to_unix_server */
  1255. + #endif /* UNIX_DOMAIN_SOCKETS */
  1256. + #ifdef INTERNET_DOMAIN_SOCKETS
  1257. + /*
  1258. +   internet_addr -- return the internet addr of the hostname or
  1259. +                    internet address passed. Return -1 on error.
  1260. + */
  1261. + u_long internet_addr(host)
  1262. +      char *host;
  1263. + {
  1264. +   struct hostent *hp;        /* pointer to host info for remote host */
  1265. +   u_long host_addr;        /* host address */
  1266. +   if ((host_addr = inet_addr(host)) != -1)
  1267. +     return host_addr;
  1268. +   else if ((hp = gethostbyname(host)) != NULL)
  1269. +     return ((struct in_addr *)(hp->h_addr))->s_addr;
  1270. +   else
  1271. +     return -1;
  1272. + } /* internet_addr */
  1273. + /*
  1274. +   connect_to_internet_server -- establish connection with server process via 
  1275. +                   an internet domain socket. Returns socket
  1276. +                 descriptor for server if successful.
  1277. + */
  1278. + int connect_to_internet_server(serverhost,port)
  1279. +      char *serverhost;
  1280. +      u_short port;
  1281. + {
  1282. +   int s;                /* connected socket descriptor */
  1283. +   struct servent *sp;            /* pointer to service information */
  1284. +   struct sockaddr_in peeraddr_in;    /* for peer socket address */
  1285. +   /* clear out address structures */
  1286. +   bzero((char *)&peeraddr_in,sizeof(struct sockaddr_in));
  1287. +   
  1288. +   /* Set up the peer address to which we will connect. */
  1289. +   peeraddr_in.sin_family = AF_INET;
  1290. +   /* look up the server host's internet address */
  1291. +   if ((peeraddr_in.sin_addr.s_addr = internet_addr(serverhost)) == -1) {
  1292. +     fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP\n",
  1293. +         progname,serverhost);
  1294. +     exit(1);
  1295. +   }; /* if */
  1296. +   
  1297. +   if (port == 0) {
  1298. +     if ((sp = getservbyname ("gnuserv","tcp")) == NULL)
  1299. +       peeraddr_in.sin_port = htons(DEFAULT_PORT+getuid());
  1300. +     else
  1301. +       peeraddr_in.sin_port = sp->s_port;
  1302. +   } /* if */
  1303. +   else
  1304. +     peeraddr_in.sin_port = htons(port);
  1305. +   
  1306. +   /* Create the socket. */
  1307. +   if ((s = socket (AF_INET,SOCK_STREAM, 0))== -1) {
  1308. +     perror(progname);
  1309. +     fprintf(stderr,"%s: unable to create socket\n",progname);
  1310. +     exit(1);
  1311. +   }; /* if */
  1312. +   
  1313. +   /* Try to connect to the remote server at the address
  1314. +    * which was just built into peeraddr.
  1315. +    */
  1316. +   if (connect(s, &peeraddr_in, sizeof(struct sockaddr_in)) == -1) {
  1317. +     perror(progname);
  1318. +     fprintf(stderr, "%s: unable to connect to remote\n",progname);
  1319. +     exit(1);
  1320. +   }; /* if */
  1321. +   
  1322. +   return(s);
  1323. + } /* connect_to_internet_server */
  1324. + #endif /* INTERNET_DOMAIN_SOCKETS */
  1325. + #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
  1326. + /*
  1327. +   disconnect_from_server -- inform the server that sending has finished, and wait for
  1328. +                             its reply.
  1329. + */
  1330. + void disconnect_from_server(s,echo)
  1331. +      int s;
  1332. +      int echo;
  1333. + {
  1334. +   char buffer[REPLYSIZ];
  1335. +   int length;
  1336. +   send_string(s,"\n");        /* make sure server gets string */
  1337. +   if (shutdown(s,1) == -1) {
  1338. +     perror(progname);
  1339. +     fprintf(stderr, "%s: unable to shutdown socket\n",progname);
  1340. +     exit(1);
  1341. +   }; /* if */
  1342. +   while((length = recv(s,buffer,REPLYSIZ,0)) > 0) {
  1343. +     buffer[length] = '\0';
  1344. +     if (echo) printf("%s",buffer);
  1345. +   }; /* while */
  1346. +   
  1347. +   if (echo) putchar('\n');
  1348. +   if(length < 0) {
  1349. +     perror(progname);
  1350. +     fprintf(stderr,"%s: unable to read the reply from the server\n",progname);
  1351. +     exit(1);
  1352. +   }; /* if */
  1353. + } /* disconnect_from_server */  
  1354. + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
  1355. *** ./Makefile.in    Tue Aug 20 00:12:19 1996
  1356. --- ../emacs-19.34/./Makefile.in    Fri May 15 10:42:41 1998
  1357. ***************
  1358. *** 253,264 ****
  1359.   .RECURSIVE: ${SUBDIR}
  1360.   
  1361.   ${SUBDIR}: ${SUBDIR_MAKEFILES} FRC
  1362. !     cd $@; $(MAKE) all $(MFLAGS) \
  1363.         CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
  1364.         LDFLAGS='${LDFLAGS}' MAKE='${MAKE}'
  1365.   
  1366.   blessmail: ${SUBDIR_MAKEFILES} src FRC
  1367. !     cd lib-src; $(MAKE) maybe-blessmail $(MFLAGS) \
  1368.         MAKE='${MAKE}' archlibdir='$(archlibdir)'
  1369.   
  1370.   Makefile: Makefile.in config.status
  1371. --- 253,264 ----
  1372.   .RECURSIVE: ${SUBDIR}
  1373.   
  1374.   ${SUBDIR}: ${SUBDIR_MAKEFILES} FRC
  1375. !     cd $@; $(MAKE) $(MFLAGS) all \
  1376.         CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
  1377.         LDFLAGS='${LDFLAGS}' MAKE='${MAKE}'
  1378.   
  1379.   blessmail: ${SUBDIR_MAKEFILES} src FRC
  1380. !     cd lib-src; $(MAKE) $(MFLAGS) maybe-blessmail \
  1381.         MAKE='${MAKE}' archlibdir='$(archlibdir)'
  1382.   
  1383.   Makefile: Makefile.in config.status
  1384. ***************
  1385. *** 304,310 ****
  1386.   ### to ensure that install-arch-indep finishes before this starts.
  1387.   install-arch-dep: mkdir
  1388.       (cd lib-src; \
  1389. !       $(MAKE) install $(MFLAGS) prefix=${prefix} \
  1390.           exec_prefix=${exec_prefix} bindir=${bindir} \
  1391.           libexecdir=${libexecdir} archlibdir=${archlibdir})
  1392.       ${INSTALL_PROGRAM} src/emacs ${bindir}/emacs-${version}
  1393. --- 304,310 ----
  1394.   ### to ensure that install-arch-indep finishes before this starts.
  1395.   install-arch-dep: mkdir
  1396.       (cd lib-src; \
  1397. !       $(MAKE) $(MFLAGS) install prefix=${prefix} \
  1398.           exec_prefix=${exec_prefix} bindir=${bindir} \
  1399.           libexecdir=${libexecdir} archlibdir=${archlibdir})
  1400.       ${INSTALL_PROGRAM} src/emacs ${bindir}/emacs-${version}
  1401. ***************
  1402. *** 471,479 ****
  1403.   ###      `make distclean' should leave only the files that were in the
  1404.   ###      distribution.
  1405.   top_distclean=\
  1406. !     rm -f config.status config.cache config.log ; \
  1407.       rm -f Makefile ${SUBDIR_MAKEFILES} ; \
  1408. !     (cd lock && (rm * || true))
  1409.   distclean: FRC
  1410.       (cd src;      $(MAKE) $(MFLAGS) distclean)
  1411.       (cd oldXMenu; $(MAKE) $(MFLAGS) distclean)
  1412. --- 471,479 ----
  1413.   ###      `make distclean' should leave only the files that were in the
  1414.   ###      distribution.
  1415.   top_distclean=\
  1416. !     -rm -f config.status config.cache config.log ; \
  1417.       rm -f Makefile ${SUBDIR_MAKEFILES} ; \
  1418. !     (test -d lock && cd lock && (rm * || true))
  1419.   distclean: FRC
  1420.       (cd src;      $(MAKE) $(MFLAGS) distclean)
  1421.       (cd oldXMenu; $(MAKE) $(MFLAGS) distclean)
  1422. Binary files ./site-lisp/gnuserv.elc and ../emacs-19.34/./site-lisp/gnuserv.elc differ
  1423. *** ./site-lisp/gnuserv.el    Thu May 21 11:32:03 1998
  1424. --- ../emacs-19.34/./site-lisp/gnuserv.el    Fri May 15 10:37:38 1998
  1425. ***************
  1426. *** 0 ****
  1427. --- 1,366 ----
  1428. + ; Lisp Interface code between GNU Emacs and gnuserv.
  1429. + ;
  1430. + ; This file is part of GNU Emacs.
  1431. + ;
  1432. + ; Copying is permitted under those conditions described by the GNU
  1433. + ; General Public License.
  1434. + ;
  1435. + ; Copyright (C) 1989 Free Software Foundation, Inc.
  1436. + ;
  1437. + ; Author: Andy Norman (ange@hplb.hpl.hp.com) based on
  1438. + ;         'lisp/server.el' from the 18.52 GNU Emacs distribution.
  1439. + ;
  1440. + ; Please mail bugs and suggestions to the author at the above address.
  1441. + (defconst gnuserv-rcs-header-id "$Header: /usr/xtmp/khera/emacs-19.12/site-lisp/gnuserv.el,v 1.3 1993/06/03 15:11:00 khera Exp $")
  1442. + (provide 'gnuserv)
  1443. + (defvar server-program (concat exec-directory "gnuserv")
  1444. +   "*The program to use as the edit server")
  1445. + (defvar server-process nil 
  1446. +   "the current server process")
  1447. + (defvar server-string ""
  1448. +   "the last input string from the server")
  1449. + (defvar current-client nil
  1450. +   "the client we are currently talking to")
  1451. + (defvar server-clients nil
  1452. +   "List of current server clients.
  1453. + Each element is (CLIENTID BUFFER...) where CLIENTID is an integer
  1454. + that can be given to the server process to identify a client.
  1455. + When a buffer is killed, it is removed from this list.")
  1456. + (defvar server-buffer-clients nil
  1457. +   "List of clientids for clients requesting editing of current buffer.")
  1458. + (make-variable-buffer-local 'server-buffer-clients)
  1459. + (setq-default server-buffer-clients nil)
  1460. + (or (assq 'server-buffer-clients minor-mode-alist)
  1461. +     (setq minor-mode-alist (cons '(server-buffer-clients " Server") minor-mode-alist)))
  1462. + (defun server-log (string)
  1463. +   "If a *server* buffer exists, write STRING to it for logging purposes."
  1464. +   (if (get-buffer "*server*")
  1465. +       (save-excursion
  1466. +     (set-buffer "*server*")
  1467. +     (goto-char (point-max))
  1468. +     (insert string)
  1469. +     (or (bolp) (newline)))))
  1470. + (defun server-sentinel (proc msg)
  1471. +   (cond ((eq (process-status proc) 'exit)
  1472. +      (server-log (message "Server subprocess exited")))
  1473. +     ((eq (process-status proc) 'signal)
  1474. +      (server-log (message "Server subprocess killed")))))
  1475. + (defun server-process-display-error (string)
  1476. +   "When an error has been reported from the server, display the error in a
  1477. + pop-up window."
  1478. +   (let ((cur (selected-window))
  1479. +     (pop-up-windows t))
  1480. +     (pop-to-buffer (get-buffer-create "*server*"))
  1481. +     (set-window-start (selected-window) (point))
  1482. +     (server-log string)
  1483. +     (select-window cur)))
  1484. +     
  1485. + (defun server-process-filter (proc string)
  1486. +   "Process incoming requests from the server for GNU Emacs to do some actions."
  1487. +   (setq server-string (concat server-string string))
  1488. +   (if (string-match "\n$" server-string) ;wait till request ends with a newline
  1489. +       (if (string-match "^[0-9]+" server-string) ;client request id
  1490. +     (progn
  1491. +       (server-log server-string)
  1492. +       (let ((header (read-from-string server-string)))
  1493. +         (setq current-client (car header))
  1494. +         (condition-case oops
  1495. +         (eval (car (read-from-string server-string (cdr header))))
  1496. +           (error (setq server-string "")
  1497. +              (server-write-to-client current-client oops)
  1498. +              (setq current-client nil)
  1499. +              (signal (car oops) (cdr oops)))
  1500. +           (quit (setq server-string "")
  1501. +             (server-write-to-client current-client oops)
  1502. +             (setq current-client nil)
  1503. +             (signal 'quit nil)))
  1504. +         (setq server-string "")))
  1505. +     (progn                ;error string from server
  1506. +       (server-process-display-error server-string)
  1507. +       (setq server-string "")))))
  1508. + (defun server-release-outstanding-buffers ()
  1509. +   "Release all buffers that have clients waiting for them to be finished."
  1510. +   (interactive)
  1511. +   (while server-clients
  1512. +     (let ((buffer (nth 1 (car server-clients)))) ;need to do this for all buffers
  1513. +       (server-buffer-done buffer))))    ; destructively modifies server-clients
  1514. + (defun server-start (&optional leave-dead)
  1515. +   "Allow this Emacs process to be a server for client processes.
  1516. + This starts a server communications subprocess through which
  1517. + client \"editors\" can send editing commands to this Emacs job.
  1518. + Prefix arg means just kill any existing server communications subprocess."
  1519. +   (interactive "P")
  1520. +   ;; kill it dead!
  1521. +   (if server-process
  1522. +       (progn
  1523. +     (server-release-outstanding-buffers)
  1524. +     (set-process-sentinel server-process nil)
  1525. +     (condition-case ()
  1526. +         (delete-process server-process)
  1527. +       (error nil))))
  1528. +   ;; If we already had a server, clear out associated status.
  1529. +   (if leave-dead
  1530. +       nil
  1531. +     (if server-process
  1532. +     (server-log (message "Restarting server")))
  1533. +     (setq server-string "")
  1534. +     (setq current-client nil)
  1535. +     (let ((process-connection-type t))
  1536. +       (setq server-process (start-process "server" nil server-program)))
  1537. +     (set-process-sentinel server-process 'server-sentinel)
  1538. +     (set-process-filter server-process 'server-process-filter)
  1539. +     (process-kill-without-query server-process)))
  1540. + (defun server-write-to-client (client form)
  1541. +   "Write the given form to the given client via the server process."
  1542. +   (if (and client
  1543. +        (eq (process-status server-process) 'run))
  1544. +       (let ((s (format "%s:%s\n" client form)))
  1545. +     (send-string server-process s)
  1546. +     (server-log s))))
  1547. + (defun server-eval (form)
  1548. +   "Evaluate form and return result to client."
  1549. +   (server-write-to-client current-client (eval form))
  1550. +   (setq current-client nil))
  1551. + (defun server-eval-quickly (form)
  1552. +   "Let client know that we've received the request, but eval the form
  1553. + afterwards in order to not keep the client waiting."
  1554. +   (server-write-to-client current-client nil)
  1555. +   (setq current-client nil)
  1556. +   (eval form))
  1557. + (defun server-make-window-visible ()
  1558. +   "Try to make the window visible."
  1559. +   (make-frame-visible))
  1560. + (defun server-find-file (file)
  1561. +   "Edit file FILENAME.
  1562. + Switch to a buffer visiting file FILENAME,
  1563. + creating one if none already exists."
  1564. +   (let ((obuf (get-file-buffer file)))
  1565. +     (if (and obuf (set-buffer obuf))
  1566. +     (if (file-exists-p file)
  1567. +         (if (or (not (verify-visited-file-modtime obuf))
  1568. +             (buffer-modified-p obuf))
  1569. +         (revert-buffer t nil))
  1570. +       (if (y-or-n-p
  1571. +            (concat "File no longer exists: "
  1572. +                file
  1573. +                ", write buffer to file? "))
  1574. +           (write-file file)))
  1575. +       (set-buffer (find-file-noselect file))))
  1576. +   (switch-to-buffer (current-buffer)))
  1577. + (defun server-edit-files-quickly (l)
  1578. +   "For each (lineno . file) pair in the given list, edit the file and goto the
  1579. + given line number. Note that unlike server-edit-files, no information is saved
  1580. + about clients waiting for this buffer to be killed."
  1581. +   (server-write-to-client current-client nil)
  1582. +   (setq current-client nil)
  1583. +   (server-make-window-visible)
  1584. +   (while l
  1585. +     (let ((line (car (car l)))
  1586. +       (path (cdr (car l))))
  1587. +       (server-find-file path)
  1588. +       (goto-line line))
  1589. +     (setq l (cdr l))))
  1590. + (defun server-edit-files (l)
  1591. +   "For each (lineno . file) pair in the given list, edit the given file for the
  1592. + client and save enough information such that server-kill-buffer can let the client
  1593. + know when the buffer has been finished with."
  1594. +   (server-make-window-visible)
  1595. +   (while l
  1596. +     (let ((line (car (car l)))
  1597. +       (path (cdr (car l))))
  1598. +       (server-find-file path)
  1599. +       (let ((old-clients (assq current-client server-clients))
  1600. +         (buffer (current-buffer)))
  1601. +     (goto-line line)
  1602. +     (setq server-buffer-clients
  1603. +           (cons current-client server-buffer-clients))
  1604. +     (if old-clients            ;client already waiting for buffers?
  1605. +         (nconc old-clients (list buffer)) ;yes -- append this one as well
  1606. +       (setq server-clients        ;nope -- make a new record
  1607. +         (cons (list current-client buffer)
  1608. +               server-clients)))))
  1609. +       (setq l (cdr l)))
  1610. +   (message (substitute-command-keys
  1611. +         "When done with a buffer, type \\[server-edit].")))
  1612. + (defun server-get-buffer (buffer)
  1613. +   "One arg, a string or a buffer. Return either a buffer object or
  1614. + throw an error if the buffer named was not a buffer."
  1615. +   (if (null buffer)
  1616. +       (current-buffer)
  1617. +     (let ((buf (get-buffer buffer)))
  1618. +       (if (null buf)
  1619. +       (if (stringp buffer)
  1620. +           (error "No buffer named %s" buffer)
  1621. +         (error "Invalid buffer argument"))
  1622. +     buf))))
  1623. + (defun server-kill-buffer (buffer)
  1624. +   "One arg, a string or a buffer.  Get rid of the specified buffer.
  1625. + NOTE: This function has been enhanced to allow for remote editing
  1626. + in the following way:
  1627. + If the buffer is waited upon by one or more clients, and a client is
  1628. + not waiting for other buffers to be killed, then the client is told
  1629. + that the buffer has been killed."
  1630. +   (interactive "bKill buffer ")
  1631. +   (setq buffer (server-get-buffer buffer))
  1632. +   (if (buffer-name buffer)
  1633. +       (save-excursion
  1634. +     (set-buffer buffer)
  1635. +     (let ((old-clients server-clients))
  1636. +       (server-real-kill-buffer buffer) ;try to kill it
  1637. +       (if (buffer-name buffer)    ;succeeded in killing?
  1638. +           nil            ;nope
  1639. +         (while old-clients
  1640. +           (let ((client (car old-clients)))
  1641. +         (delq buffer client)
  1642. +         (if (cdr client)    ;pending buffers?
  1643. +             nil            ;yep
  1644. +           (server-write-to-client (car client) nil) ;nope, tell client
  1645. +           (setq server-clients (delq client server-clients))))
  1646. +           (setq old-clients (cdr old-clients))))))))
  1647. + (defun server-kill-all-local-variables ()
  1648. +   "Eliminate all the buffer-local variable values of the current buffer.
  1649. + This buffer will then see the default values of all variables.
  1650. + NOTE: This function has been modified to ignore the variable 
  1651. + server-buffer-clients."
  1652. +   (let ((clients server-buffer-clients))
  1653. +     (server-real-kill-all-local-variables)
  1654. +     (if clients
  1655. +     (setq server-buffer-clients clients))))
  1656. + (or (fboundp 'server-real-kill-buffer)
  1657. +   (fset 'server-real-kill-buffer (symbol-function 'kill-buffer)))
  1658. + (fset 'kill-buffer 'server-kill-buffer)
  1659. + (or (fboundp 'server-real-kill-all-local-variables)
  1660. +     (fset 'server-real-kill-all-local-variables
  1661. +       (symbol-function 'kill-all-local-variables)))
  1662. + (fset 'kill-all-local-variables 'server-kill-all-local-variables)
  1663. + (defun server-buffer-done (buffer)
  1664. +   "Mark BUFFER as \"done\" for its client(s).
  1665. + Buries the buffer, and returns another server buffer
  1666. + as a suggestion for what to select next."
  1667. +   (let ((next-buffer nil)
  1668. +     (old-clients server-clients))
  1669. +     (while old-clients
  1670. +       (let ((client (car old-clients)))
  1671. +     (or next-buffer 
  1672. +         (setq next-buffer (nth 1 (memq buffer client))))
  1673. +     (delq buffer client)
  1674. +     ;; If client now has no pending buffers,
  1675. +     ;; tell it that it is done, and forget it entirely.
  1676. +     (if (cdr client)
  1677. +         nil
  1678. +       (server-write-to-client (car client) nil)
  1679. +       (setq server-clients (delq client server-clients))))
  1680. +       (setq old-clients (cdr old-clients)))
  1681. +     (if (buffer-name buffer)
  1682. +     (save-excursion
  1683. +       (set-buffer buffer)
  1684. +       (setq server-buffer-clients nil)))
  1685. +     (bury-buffer buffer)
  1686. +     next-buffer))
  1687. + (defun mh-draft-p (buffer)
  1688. +   "Return non-nil if this BUFFER is an mh <draft> file.
  1689. + Since MH deletes draft *BEFORE* it is edited, the server treats them specially."
  1690. +  ;; This may not be appropriately robust for all cases.
  1691. +   (string= (buffer-name buffer) "draft"))
  1692. + (defun server-done ()
  1693. +   "Offer to save current buffer, mark it as \"done\" for clients,
  1694. + bury it, and return a suggested buffer to select next."
  1695. +   (let ((buffer (current-buffer)))
  1696. +     (if server-buffer-clients
  1697. +     (progn
  1698. +        (if (mh-draft-p buffer)
  1699. +            (progn (save-buffer)
  1700. +              (write-region (point-min) (point-max)
  1701. +                    (concat buffer-file-name "~"))
  1702. +              (kill-buffer buffer))
  1703. +         (if (and (buffer-modified-p)
  1704. +              (y-or-n-p (concat "Save file " buffer-file-name "? ")))
  1705. +         (save-buffer buffer)))
  1706. +       (server-buffer-done buffer)))))
  1707. + (defun server-edit (&optional arg)
  1708. +   "Switch to next server editing buffer; say \"Done\" for current buffer.
  1709. + If a server buffer is current, it is marked \"done\" and optionally saved.
  1710. + MH <draft> files are always saved and backed up, no questions asked.
  1711. + When all of a client's buffers are marked as \"done\", the client is notified.
  1712. + If invoked with a prefix argument, or if there is no server process running, 
  1713. + starts server process and that is all.  Invoked by \\[server-edit]."
  1714. +   (interactive "P")
  1715. +   (if (or arg
  1716. +       (not server-process)
  1717. +       (memq (process-status server-process) '(signal exit)))
  1718. +       (server-start nil)
  1719. +     (server-switch-buffer (server-done))))
  1720. + (defun server-switch-buffer (next-buffer)
  1721. +   "Switch to another buffer, preferably one that has a client.
  1722. + Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it."
  1723. +   (if next-buffer
  1724. +       (if (and (bufferp next-buffer)
  1725. +            (buffer-name next-buffer))
  1726. +       (switch-to-buffer next-buffer)
  1727. +     ;; If NEXT-BUFFER is a dead buffer,
  1728. +     ;; remove the server records for it
  1729. +     ;; and try the next surviving server buffer.
  1730. +     (server-switch-buffer
  1731. +      (server-buffer-done next-buffer)))
  1732. +     (if server-clients
  1733. +     (server-switch-buffer (nth 1 (car server-clients)))
  1734. +       (switch-to-buffer (other-buffer)))))
  1735. + (global-set-key "\C-x#" 'server-edit)
  1736. *** ./configure    Tue Aug 20 00:11:26 1996
  1737. --- ../emacs-19.34/./configure    Thu May 21 11:43:36 1998
  1738. ***************
  1739. *** 1219,1224 ****
  1740. --- 1219,1236 ----
  1741.     mips-sgi-irix4* )
  1742.       machine=iris4d opsys=irix4-0
  1743.     ;;
  1744. +   mips-sgi-irix6.4 | mips-sgi-irix6.5 )
  1745. +     machine=iris4d opsys=irix6-4
  1746. +     NON_GNU_CPP='cc -E'
  1747. +     CPP=/lib/cpp
  1748. +     _ABIN32=1
  1749. +   ;;
  1750. +   mips-sgi-irix6.x )
  1751. +     machine=iris4d opsys=irix6-x
  1752. +     NON_GNU_CPP='cc -E'
  1753. +     CPP=/lib/cpp
  1754. +     _ABIN32=1
  1755. +   ;;
  1756.     mips-sgi-irix6* )
  1757.       machine=iris4d opsys=irix6-0
  1758.       NON_GNU_CPP=/lib/cpp
  1759. ***************
  1760. *** 3641,3647 ****
  1761.       builtin and then its argument prototype would still apply.  */
  1762.   char $ac_func();
  1763.   
  1764. ! int main() { return 0; }
  1765.   int t() {
  1766.   
  1767.   /* The GNU C library defines this for functions which it implements
  1768. --- 3653,3659 ----
  1769.       builtin and then its argument prototype would still apply.  */
  1770.   char $ac_func();
  1771.   
  1772. ! int main() { return t(); }
  1773.   int t() {
  1774.   
  1775.   /* The GNU C library defines this for functions which it implements
  1776.